#include <cstdio>
#include <tr1/unordered_map>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;
using namespace std::tr1;

const int MAXN = 6e5+10;
const int LIM = 6e5;
const int BLOCK = 4e4+10;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

unordered_map <int,int> ansmu;
unordered_map <int,ll> ansphi;

int mu[MAXN],phi[MAXN],smu[MAXN],prime[MAXN],primenum;
ll sphi[MAXN];
bool np[MAXN];

void shai(){
	for(int i = 2;i <= LIM;i++){
		if(!np[i]){
			prime[++primenum] = i;
			phi[i] = i-1;
			mu[i] = -1;
		}
		for(int j = 1;j <= primenum && prime[j] * i <= LIM;j++){
			np[prime[j] * i] = 1;
			if(i % prime[j] == 0){
				phi[prime[j] * i] = prime[j] * phi[i];
				mu[prime[j] * i] = 0;
				break;
			}
			else{
				phi[prime[j] * i] = phi[prime[j]] * phi[i];
				mu[prime[j] * i] = -mu[i];
			}
		}
	}
	mu[1] = 1; phi[1] = 1;
	for(int i = 1;i <= LIM;i++) sphi[i] = sphi[i-1] + phi[i],smu[i] = smu[i-1] + mu[i];
}

ll gphi(uint x){
	if(x <= LIM) return sphi[x];
	if(ansphi[x]) return ansphi[x];
	ll ans = (ull)x * (x + 1) / 2;
	for(uint l = 2,r;l <= x;l = r+1){
		r = min(x/(x/l),(uint)x);
		ans = ans - (r-l+1) * gphi(x/l);
	}
	return ansphi[x] = ans;
}

int gmu(uint x){
	if(x <= LIM) return smu[x];
	if(ansmu[x]) return ansmu[x];
	ll ans = 1;
	for(uint l = 2,r;l <= x;l = r+1){
		r = min(x/(x/l),(uint)x);
		ans = ans - (r-l+1) * gmu(x/l);
	}
	return ansmu[x] = ans;
}

int main (){
	shai();
	int T;scanf("%d",&T);
	while(T--){
		int n; scanf("%d",&n);
		printf("%lld %d\n",gphi(n),gmu(n));
	}
	return 0;
}
